package com.asw.springboot.common.redis;

import java.util.Collection;
import java.util.concurrent.TimeUnit;

/**
 * Created by hxq on 2017/5/15.
 */
public interface IGlobalRedisService{

    /***
     * 检查redis 中是否存在key
     * @param key
     * @return
     */
    public Boolean hasKey(String key);

    /***
     * 从缓存中得到字符串
     * @param key
     * @return
     */
    public String getString(String key);

    /***
     * 存储字符串
     * @param key
     * @param str
     * @param seconds
     */
    public void setString(String key, String str, int seconds);

    /***
     * 删除单个key
     * @param key
     */
   public void deleteRedisByKey(String key);
    /***
     * 删除集合key
     * @param keys
     */
    public void deleteRedisByKey(Collection keys);

    /***
     * 某个key加锁
     * @param key
     * @param seconds ，多少秒的锁时间
     * @return
     */
    public boolean redisLock(String key,int seconds);

    /***
     * 更新key过期时间
     * @param key
     * @param seconds
     * @param timeUnit
     * @return
     */
    public boolean expire(String key,int seconds,TimeUnit timeUnit);

}
